const { getRow, getAll,exec } = require("../util/dbutil");

const getReservationList = () => {
  return getAll(`select * from reservation`);
};

const getReservationDetail = (id) => {
  return getRow(`select * from reservation where id = ?`, [id]);
};
const getReservationReservation = (data) => {
  const sql = Object.keys(data).join(",");
  const seizeASeat = Object.keys(data).fill("?").join(",");
  const valuesData = Object.values(data);
  return exec(
    `INSERT INTO reservation (${sql}) VALUES (${seizeASeat})`,
    valuesData
  );
};
module.exports = {
  getReservationList,
  getReservationDetail,
  getReservationReservation,
};
